#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START bison-native

save_CFLAGS="$CFLAGS"
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
export CFLAGS='-O2 -g'
unset CPPFLAGS
unset LDFLAGS

reset_mtime bison bison/configure.ac
mkdir -p build/bison-native
cd build/bison-native
env \
	-u CPPFLAGS \
	-u LDFLAGS \
	CFLAGS='-O2 -g' \
../../bison/configure \
	--host="$BUILD" \
	--build="$BUILD" \
	--prefix="${xtools}${build_prefix}" \
	--disable-shared \
	${AUTOCRAP_KLUDGE}

make -j${JOBS}
# XXX: bison is not relocatable and *must* be installed exactly
# to prefix given to configure
make -j${JOBS} install
wipe_la_files "$xtools"
cd ../..
rm -rf build/bison-native

export CFLAGS="$save_CFLAGS"
export CPPFLAGS="$save_CPPFLAGS"
export LDFLAGS="$save_LDFLAGS"

# RECIPE END bison-native
